#!/bin/bash
if [ $# -ne 4 ]
then
	echo "usage: ./bench.sh minForPrefetch startBits lastBits vorpal_file"
	exit 65
fi
for((i=$2; i<=$3; i+=1)); do
	echo -n "$i "
	echo "#define kBitsInInstruction $i" > src/Tmp.h
	echo "#define kMinBitsToPrefetchGetSet $1" >> src/Tmp.h
	./build -n vorpal > bench.tmp
	bin/vorpal -c tulgey/apps/tiles.vorpal > bench.tmp
	bin/vorpal $4 >> bench.tmp
	grep -o 'code.*' bench.tmp | egrep -o [0-9]+ > result.tmp
	grep -o 'elapsed =.*' bench.tmp  | egrep -o [0-9]+ >> result.tmp
	paste -s -d ' ' result.tmp
	rm bench.tmp
	rm result.tmp
done
